package icu.groot.alan.util;

import lombok.Data;

@Data
public class R {
    private int code;
    private String msg;
    private Object data;

    public static R ok(String msg) {
        R r = new R();
        r.setMsg(msg);
        r.setCode(200);
        return r;
    }

    public R put(Object val) {
        data = val;
        return this;
    }
    public static R error(String msg) {
        R r = new R();
        r.setMsg(msg);
        r.setCode(400);
        return r;
    }
    public static R errorBySystemException() {
        R r = new R();
        r.setMsg("系统异常，请联系老师或则管理员处理");
        r.setCode(400);
        return r;
    }
    public static R errorByRequestParam() {
        R r = new R();
        r.setMsg("请求参数错误");
        r.setCode(400);
        return r;
    }
    public static R errorByRequestMethod() {
        R r = new R();
        r.setMsg("请求参数错误");
        r.setCode(400);
        return r;
    }
}
